Avoid the need for define __func__ "unknown" on some vendor compilers
authorMartin Nordholts <martinn@src.gnome.org>
Tue, 31 Mar 2009 17:09:42 +0000 (17:09 +0000)
committerMartin Nordholts <martinn@src.gnome.org>
Tue, 31 Mar 2009 17:09:42 +0000 (17:09 +0000)
Patch from Gary V. Vaughan

svn path=/trunk/; revision=408

ChangeLog
babl/babl-internal.h

index 7cba28cd3c00d9b013d63c3410ab9a009cf8d5ba..ab333ef51767ad3408ba041583e539f00ef63049 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-31  Martin Nordholts  <martinn@svn.gnome.org>
+
+       * babl/babl-internal.h: Patch from Gary V. Vaughan. Avoid the need
+       for define __func__ "unknown" on some vendor compilers
+
 2009-03-31  Martin Nordholts  <martinn@svn.gnome.org>
 
        * configure.ac: Patch from Gary V. Vaughan. Don't try to pass gcc
index a83e50665f2e38d3867dd63c4d4211a4f9c74c69..884b9715e0debbbc6688f2d9920c3b353e11948a 100644 (file)
@@ -162,6 +162,17 @@ real_babl_log (const char *file,
   hack_hack ();
 }
 
+/* Provide a string identifying the current function, non-concatenatable */
+#ifndef G_STRFUNC
+#if defined (__GNUC__)
+#  define G_STRFUNC     ((const char*) (__PRETTY_FUNCTION__))
+#elif defined (G_HAVE_ISO_VARARGS)
+#  define G_STRFUNC     ((const char*) (__func__))
+#else
+#  define G_STRFUNC     ((const char*) ("???"))
+#endif
+#endif
+
 #if defined(__cplusplus) && defined(BABL_ISO_CXX_VARIADIC_MACROS)
 #  define BABL_ISO_VARIADIC_MACROS 1
 #endif
@@ -169,20 +180,20 @@ real_babl_log (const char *file,
 #if defined(BABL_ISO_VARIADIC_MACROS)
 
 #define babl_log(...)                                       \
-  real_babl_log(__FILE__, __LINE__, __func__, __VA_ARGS__)
+  real_babl_log(__FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
 
 #define babl_fatal(...) do{                                \
-  real_babl_log(__FILE__, __LINE__, __func__, __VA_ARGS__); \
+  real_babl_log(__FILE__, __LINE__, G_STRFUNC, __VA_ARGS__); \
   babl_die();}                                              \
 while(0)
 
 #elif defined(BABL_GNUC_VARIADIC_MACROS)
 
 #define babl_log(args...)                               \
-  real_babl_log(__FILE__, __LINE__, __func__, args)
+  real_babl_log(__FILE__, __LINE__, G_STRFUNC, args)
 
 #define babl_fatal(args...) do{                         \
-  real_babl_log(__FILE__, __LINE__, __func__, args);    \
+  real_babl_log(__FILE__, __LINE__, G_STRFUNC, args);    \
   babl_die();}                                          \
 while(0)
 
@@ -193,7 +204,7 @@ babl_log (const char *format, ...)
 {
   va_list args;
   va_start (args, format);
-  real_babl_log (__FILE__, __LINE__, __func__, format, args);
+  real_babl_log (__FILE__, __LINE__, G_STRFUNC, format, args);
   va_end (args);
 }
 static inline void
@@ -201,7 +212,7 @@ babl_fatal (const char *format, ...)
 {
   va_list args;
   va_start (args, format);
-  real_babl_log (__FILE__, __LINE__, __func__, format, args);
+  real_babl_log (__FILE__, __LINE__, G_STRFUNC, format, args);
   va_end (args);
   babl_die();
 }
@@ -212,7 +223,7 @@ babl_fatal (const char *format, ...)
 #define babl_assert(expr) do{                              \
   if(!(expr))                                              \
     {                                                      \
-      real_babl_log(__FILE__, __LINE__, __func__, "Eeeeek! Assertion failed: `" #expr "`"); \
+      real_babl_log(__FILE__, __LINE__, G_STRFUNC, "Eeeeek! Assertion failed: `" #expr "`"); \
       assert(expr);                                        \
     }                                                      \
 }while(0)
@@ -288,13 +299,13 @@ babl_##klass (const char *name)                               \
                                                               \
   if (babl_hmpf_on_name_lookups)                              \
     {                                                         \
-      babl_log ("%s(\"%s\"): hmpf!", __func__, name);         \
+      babl_log ("%s(\"%s\"): hmpf!", G_STRFUNC, name);        \
     }                                                         \
   babl = babl_db_exist_by_name (db, name);                    \
                                                               \
   if (!babl)                                                  \
     {                                                         \
-      babl_fatal ("%s(\"%s\"): not found", __func__, name);   \
+      babl_fatal ("%s(\"%s\"): not found", G_STRFUNC, name);  \
     }                                                         \
   return babl;                                                \
 }                                                             \
@@ -306,7 +317,7 @@ babl_##klass##_from_id (int id)                               \
   babl = babl_db_exist_by_id (db, id);                        \
   if (!babl)                                                  \
     {                                                         \
-      babl_fatal ("%s(%i): not found", __func__, id);         \
+      babl_fatal ("%s(%i): not found", G_STRFUNC, id);        \
     }                                                         \
   return babl;                                                \
 }